const tools ={
  formatDate:(date,format = 'yyyy-MM-dd hh:mm:ss') => {
    let info = date;
    //如果是时间戳，就转换为日期对象
    if(typeof date === 'number'){
      info = new Date();
      info.setTime(date);
    }
    //格式化日期为字符串
    let year = info.getFullYear();
    let month = info.getMonth() + 1;
    let day = info.getDate();
    let hour = info.getHours();
    let minute = info.getMinutes();
    let second = info.getSeconds();
    let result = format.replace('yyyy',year);
    result = result.replace('MM',month < 10 ? '0' + month : month);
    result = result.replace('dd',day < 10 ? '0' + day : day);
    result = result.replace('hh',hour < 10 ? '0' + hour : hour);
    result = result.replace('mm',minute < 10 ? '0' + minute : minute);
    result = result.replace('ss',second < 10 ? '0' + second : second);
    return result;
  },
  //合并多个json为一个
  mergeJson:(...jsons) => {
  let result = {};
  //循环获取多个json值
  for(let json of jsons) {
    //循环获取json的key和数据
    for(let key in json) {
      result[key] = json[key];
    }
  }
  return result;
  },
};

export { tools as default, tools as tools};